﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using UAXInversionesWeb.logicaNegocio;

namespace UAXInversionesWeb.cliente
{
    public partial class SolicitarBaja : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Proxy.isLogged())
            {
                int idcliente = (int)HttpContext.Current.Session["identificador"];

                idCliente.Text = idcliente.ToString();

                bool yaSolicitada = Proxy.comprobarSolicitudBaja(idcliente);
                if (yaSolicitada)
                {
                    panelSolicitudBaja.Visible = false;
                    yaSolicitadaPanel.Visible = true;
                }

            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            int idclient = (int)HttpContext.Current.Session["identificador"];

            bool result = Proxy.solicitarBaja(idclient, motivos.Text, password.Text);

            if (result)
            {
                panelSolicitudBaja.Visible = false;
                yaSolicitadaPanel.Visible = true;
               
            }
            else
            {
                mensaje.Text = "Error al enviar la solicitud.";
               
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            motivos.Text = "";
            password.Text = "";
        }

        protected void continueButton_Click(object sender, EventArgs e)
        {
            Response.Redirect("PaginaPrincipalCliente.aspx");
        }
    }
}
